home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-30 | 14.9 KB | 580 lines | [TEXT/CWIE] |
- { Bars.p }
- { Created 10/30/98 1:06 PM by AppMaker }
-
- Unit Bars;
- Interface
-
- Uses
- Types,
- Quickdraw,
- Controls,
- Dialogs,
- Events,
- Lists,
- Menus,
- Resources,
- TextEdit,
- ToolUtils,
-
- DDocData,
- EverythingEngine,
- EverythingDoc,
- AMWindow;
-
- type
- Bars = object (AMWindow)
-
- {data members}
- mData: DDocData;
- mBarsHandle: ControlHandle;
- mScrollBarsHandle: ControlHandle;
- mStandard4Handle: ControlHandle;
- mGraphic4Handle: ControlHandle;
- mSliderHandle: ControlHandle;
- mTickMarksHandle: ControlHandle;
- mNonDirectionalHandle: ControlHandle;
- mLittleArrowsHandle: ControlHandle;
- mSpinnerHandle: ControlHandle;
- mVolumeControlHandle: ControlHandle;
- mJimSSliderHandle: ControlHandle;
- mProgressBarsHandle: ControlHandle;
- mStandard5Handle: ControlHandle;
- mIndeterminateHandle: ControlHandle;
- mChasingArrowsHandle: ControlHandle;
- mRectangleHandle: ControlHandle;
- mRoundRectHandle: ControlHandle;
- mBarberPoleHandle: ControlHandle;
- mRoundBarberHandle: ControlHandle;
-
- {methods}
- Procedure Initialize; Override;
-
- Procedure Open (inDoc: EverythingDoc;
- inData: DDocData);
- Procedure Close; Override;
-
- Procedure Control (whichControl: ControlHandle;
- whichPart: integer;
- where: Point); Override;
- Procedure MouseIn (where: Point;
- modifiers: integer); Override;
- Procedure TypeIn (charCode: SInt16); Override;
- Procedure ExitCurField; Override;
- Procedure DataChanged (inDataID: longint); Override;
- Procedure Resize; Override;
- Procedure Scroll (newValue: integer;
- oldValue: integer); Override;
-
- Function GetEngine: EverythingEngine;
-
- {$ifc false}
- Procedure UpdateMenus; Override;
- {$endif}
- Function DoCommand (inCommand: longint): Boolean; Override;
-
- Procedure DoUndo;
- Procedure DoCut;
- Procedure DoCopy;
- Procedure DoPaste;
- Procedure DoClear;
- Procedure DoSelectAll;
- Procedure DoShowClipboard;
-
- end;
-
- {----------}
- Procedure CreateBars (inDoc: EverythingDoc;
- inData: DDocData);
-
- {----------}
- Implementation
-
- Uses
- Globals,
- ResourceDefs,
- DoScrap,
- Scrolling,
- ControlUtils,
- Miscellany;
-
- const
- kBarsPanel = 1;
- kScrollBarsLayer = 2;
- kStandard4Scroll = 3;
- kGraphic4Scroll = 4;
- kSliderScroll = 5;
- kTickMarksScroll = 6;
- kNonDirectionalScroll = 7;
- kLittleArrowsScroll = 8;
- kSpinnerScroll = 9;
- kVolumeControlScroll = 10;
- kJimSSliderScroll = 11;
- kProgressBarsLayer = 12;
- kStandard5Bar = 13;
- kIndeterminateBar = 14;
- kChasingArrowsBar = 15;
- kRectangleBar = 16;
- kRoundRectBar = 17;
- kBarberPoleBar = 18;
- kRoundBarberBar = 19;
-
- {----------}
- Procedure CreateBars (
- inDoc: EverythingDoc;
- inData: DDocData);
- var
- winObj: Bars;
- begin
- winObj := nil;
- New (winObj);
-
- if winObj <> nil then begin
- winObj.Initialize;
- winObj.Open (inDoc, inData);
- end;
- end;
-
- {----------}
- Procedure Bars.Initialize;
- begin
- Inherited Initialize;
- end;
-
- {----------}
- Function Bars.GetEngine: EverythingEngine;
- begin
- GetEngine := EverythingEngine (mDoc.mEngine);
- end;
-
- {----------}
- Procedure Bars.Open (
- inDoc: EverythingDoc;
- inData: DDocData);
- var
- window: WindowPtr;
- wftb: Handle;
- errCode: OSErr;
- begin
- mDoc := inDoc;
- mData := inData;
- mData.AddResponder (self);
-
- window := GetNewCWindow (WIND_Bars, nil, WindowPtr (-1));
- if inDoc.mEngine.GetFilename <> '' then begin
- SetWTitle (window, inDoc.mEngine.GetFilename);
- end;
- mWindow := window;
- EverythingDoc (mDoc).mBarsPtr := window;
-
- WindowPeek (window)^.windowKind := kAMWindowFlag;
- SetWRefCon (window, ord4 (self));
- SetPort (window);
- SetInfo (window);
-
- wftb := GetResource ('Wftb', WIND_Bars);
-
- errCode := CreateRootControl (window, mRootControl);
-
- vScroll := nil;
- hScroll := nil;
-
-
- mBarsHandle := GetNewControl (CNTL_Bars, window);
- SetWindowItemFont (mBarsHandle, wftb, 1);
- SetControlValue (mBarsHandle, mData.GetBars);
- SetLayerGroupValue (mBarsHandle, mData.GetBars);
-
- mScrollBarsHandle := GetNewControl (CNTL_ScrollBars, window);
- errCode := EmbedControl (mScrollBarsHandle, mBarsHandle);
- SetWindowItemFont (mScrollBarsHandle, wftb, 2);
-
- mStandard4Handle := GetNewControl (CNTL_Standard4, window);
- errCode := EmbedControl (mStandard4Handle, mScrollBarsHandle);
- SetWindowItemFont (mStandard4Handle, wftb, 3);
- SetControlValue (mStandard4Handle, mData.GetStandard2);
-
- mGraphic4Handle := GetNewControl (CNTL_Graphic4, window);
- errCode := EmbedControl (mGraphic4Handle, mScrollBarsHandle);
- SetWindowItemFont (mGraphic4Handle, wftb, 4);
- SetControlValue (mGraphic4Handle, mData.GetGraphic2);
-
- mSliderHandle := GetNewControl (CNTL_Slider, window);
- errCode := EmbedControl (mSliderHandle, mScrollBarsHandle);
- SetWindowItemFont (mSliderHandle, wftb, 5);
- SetControlValue (mSliderHandle, mData.GetSlider);
-
- mTickMarksHandle := GetNewControl (CNTL_TickMarks, window);
- errCode := EmbedControl (mTickMarksHandle, mScrollBarsHandle);
- SetWindowItemFont (mTickMarksHandle, wftb, 6);
- SetControlValue (mTickMarksHandle, mData.GetTickMarks);
-
- mNonDirectionalHandle := GetNewControl (CNTL_NonDirectional, window);
- errCode := EmbedControl (mNonDirectionalHandle, mScrollBarsHandle);
- SetWindowItemFont (mNonDirectionalHandle, wftb, 7);
- SetControlValue (mNonDirectionalHandle, mData.GetNonDirectional);
-
- mLittleArrowsHandle := GetNewControl (CNTL_LittleArrows, window);
- errCode := EmbedControl (mLittleArrowsHandle, mScrollBarsHandle);
- SetWindowItemFont (mLittleArrowsHandle, wftb, 8);
- SetControlValue (mLittleArrowsHandle, mData.GetLittleArrows);
-
- mSpinnerHandle := GetNewControl (CNTL_Spinner, window);
- errCode := EmbedControl (mSpinnerHandle, mScrollBarsHandle);
- SetWindowItemFont (mSpinnerHandle, wftb, 9);
- SetControlValue (mSpinnerHandle, mData.GetSpinner);
-
- mVolumeControlHandle := GetNewControl (CNTL_VolumeControl, window);
- errCode := EmbedControl (mVolumeControlHandle, mScrollBarsHandle);
- SetWindowItemFont (mVolumeControlHandle, wftb, 10);
- SetControlValue (mVolumeControlHandle, mData.GetVolumeControl);
-
- mJimSSliderHandle := GetNewControl (CNTL_JimSSlider, window);
- errCode := EmbedControl (mJimSSliderHandle, mScrollBarsHandle);
- SetWindowItemFont (mJimSSliderHandle, wftb, 11);
- SetControlValue (mJimSSliderHandle, mData.GetJimSSlider);
-
- mProgressBarsHandle := GetNewControl (CNTL_ProgressBars, window);
- errCode := EmbedControl (mProgressBarsHandle, mBarsHandle);
- SetWindowItemFont (mProgressBarsHandle, wftb, 12);
-
- mStandard5Handle := GetNewControl (CNTL_Standard5, window);
- errCode := EmbedControl (mStandard5Handle, mProgressBarsHandle);
- SetWindowItemFont (mStandard5Handle, wftb, 13);
- SetControlValue (mStandard5Handle, mData.GetStandard3);
-
- mIndeterminateHandle := GetNewControl (CNTL_Indeterminate, window);
- errCode := EmbedControl (mIndeterminateHandle, mProgressBarsHandle);
- SetWindowItemFont (mIndeterminateHandle, wftb, 14);
- SetControlValue (mIndeterminateHandle, mData.GetIndeterminate);
- SetIndeterminateState (mIndeterminateHandle, true);
-
- mChasingArrowsHandle := GetNewControl (CNTL_ChasingArrows, window);
- errCode := EmbedControl (mChasingArrowsHandle, mProgressBarsHandle);
- SetWindowItemFont (mChasingArrowsHandle, wftb, 15);
- SetControlValue (mChasingArrowsHandle, mData.GetChasingArrows);
-
- mRectangleHandle := GetNewControl (CNTL_Rectangle, window);
- errCode := EmbedControl (mRectangleHandle, mProgressBarsHandle);
- SetWindowItemFont (mRectangleHandle, wftb, 16);
- SetControlValue (mRectangleHandle, mData.GetRectangle);
-
- mRoundRectHandle := GetNewControl (CNTL_RoundRect, window);
- errCode := EmbedControl (mRoundRectHandle, mProgressBarsHandle);
- SetWindowItemFont (mRoundRectHandle, wftb, 17);
- SetControlValue (mRoundRectHandle, mData.GetRoundRect);
-
- mBarberPoleHandle := GetNewControl (CNTL_BarberPole, window);
- errCode := EmbedControl (mBarberPoleHandle, mProgressBarsHandle);
- SetWindowItemFont (mBarberPoleHandle, wftb, 18);
- SetControlValue (mBarberPoleHandle, mData.GetBarberPole);
-
- mRoundBarberHandle := GetNewControl (CNTL_RoundBarber, window);
- errCode := EmbedControl (mRoundBarberHandle, mProgressBarsHandle);
- SetWindowItemFont (mRoundBarberHandle, wftb, 19);
- SetControlValue (mRoundBarberHandle, mData.GetRoundBarber);
-
- SetLayerGroupValue (mBarsHandle, mData.GetBars);
-
- errCode := AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- end;
-
- {----------}
- Procedure Bars.Close;
- begin
- mData.RemoveResponder (self);
-
- EverythingDoc (mDoc).mBarsPtr := nil;
- SetInfo (nil);
- HideWindow (mWindow);
- DisposeWindow (mWindow);
-
- Dispose (self);
- end;
-
- {----------}
- Procedure Bars.Control (
- whichControl: ControlHandle;
- whichPart: integer;
- where: Point);
- var
- bounds: Rect;
- newValue: integer;
- partcode: SInt16;
- begin
- ExitCurField ();
-
- if whichControl = mBarsHandle then begin
- if TrackClick (mBarsHandle, where) then begin
- mData.SetBars (GetControlValue (mBarsHandle));
- end;
- end;
- if whichControl = mStandard4Handle then begin
- partCode := HandleControlClick (mStandard4Handle, where, curEvent.modifiers, nil);
- mData.SetStandard2 (GetControlValue (mStandard4Handle));
- end;
- if whichControl = mGraphic4Handle then begin
- partCode := HandleControlClick (mGraphic4Handle, where, curEvent.modifiers, nil);
- mData.SetGraphic2 (GetControlValue (mGraphic4Handle));
- end;
- if whichControl = mSliderHandle then begin
- partCode := HandleControlClick (mSliderHandle, where, curEvent.modifiers, nil);
- mData.SetSlider (GetControlValue (mSliderHandle));
- end;
- if whichControl = mTickMarksHandle then begin
- partCode := HandleControlClick (mTickMarksHandle, where, curEvent.modifiers, nil);
- mData.SetTickMarks (GetControlValue (mTickMarksHandle));
- end;
- if whichControl = mNonDirectionalHandle then begin
- partCode := HandleControlClick (mNonDirectionalHandle, where, curEvent.modifiers, nil);
- mData.SetNonDirectional (GetControlValue (mNonDirectionalHandle));
- end;
- if whichControl = mLittleArrowsHandle then begin
- partCode := HandleControlClick (mLittleArrowsHandle, where, curEvent.modifiers, nil);
- mData.SetLittleArrows (GetControlValue (mLittleArrowsHandle));
- end;
- if whichControl = mSpinnerHandle then begin
- partCode := HandleControlClick (mSpinnerHandle, where, curEvent.modifiers, nil);
- mData.SetSpinner (GetControlValue (mSpinnerHandle));
- end;
- if whichControl = mVolumeControlHandle then begin
- partCode := HandleControlClick (mVolumeControlHandle, where, curEvent.modifiers, nil);
- mData.SetVolumeControl (GetControlValue (mVolumeControlHandle));
- end;
- if whichControl = mJimSSliderHandle then begin
- partCode := HandleControlClick (mJimSSliderHandle, where, curEvent.modifiers, nil);
- mData.SetJimSSlider (GetControlValue (mJimSSliderHandle));
- end;
- end;
-
- {----------}
- Procedure Bars.DataChanged (
- inDataID: longint);
- begin
- if inDataID = idBars then begin
- SetControlValue (mBarsHandle, mData.GetBars);
- SetLayerGroupValue (mBarsHandle, mData.GetBars);
- end;
- if inDataID = idStandard2 then begin
- SetControlValue (mStandard4Handle, mData.GetStandard2);
- end;
- if inDataID = idGraphic2 then begin
- SetControlValue (mGraphic4Handle, mData.GetGraphic2);
- end;
- if inDataID = idSlider then begin
- SetControlValue (mSliderHandle, mData.GetSlider);
- end;
- if inDataID = idTickMarks then begin
- SetControlValue (mTickMarksHandle, mData.GetTickMarks);
- end;
- if inDataID = idNonDirectional then begin
- SetControlValue (mNonDirectionalHandle, mData.GetNonDirectional);
- end;
- if inDataID = idLittleArrows then begin
- SetControlValue (mLittleArrowsHandle, mData.GetLittleArrows);
- end;
- if inDataID = idSpinner then begin
- SetControlValue (mSpinnerHandle, mData.GetSpinner);
- end;
- if inDataID = idVolumeControl then begin
- SetControlValue (mVolumeControlHandle, mData.GetVolumeControl);
- end;
- if inDataID = idJimSSlider then begin
- SetControlValue (mJimSSliderHandle, mData.GetJimSSlider);
- end;
- if inDataID = idStandard3 then begin
- SetControlValue (mStandard5Handle, mData.GetStandard3);
- end;
- if inDataID = idIndeterminate then begin
- SetControlValue (mIndeterminateHandle, mData.GetIndeterminate);
- end;
- if inDataID = idChasingArrows then begin
- SetControlValue (mChasingArrowsHandle, mData.GetChasingArrows);
- end;
- if inDataID = idRectangle then begin
- SetControlValue (mRectangleHandle, mData.GetRectangle);
- end;
- if inDataID = idRoundRect then begin
- SetControlValue (mRoundRectHandle, mData.GetRoundRect);
- end;
- if inDataID = idBarberPole then begin
- SetControlValue (mBarberPoleHandle, mData.GetBarberPole);
- end;
- if inDataID = idRoundBarber then begin
- SetControlValue (mRoundBarberHandle, mData.GetRoundBarber);
- end;
- End;
-
- {----------}
- Procedure Bars.MouseIn (
- where: Point;
- modifiers: integer);
- var
- bounds: Rect;
- begin
- end;
-
- {----------}
- Procedure Bars.ExitCurField;
- var
- errCode: OSErr;
- focus: ControlHandle;
- begin
- errCode := GetKeyboardFocus (mWindow, focus);
-
- if focus = nil then begin
- { nothing to exit }
-
- end;
- inherited ExitCurField;
- end;
-
- {----------}
- Procedure Bars.TypeIn (
- charCode: SInt16);
- var
- ch: char;
- errCode: OSErr;
- focus: ControlHandle;
- keyCode: SInt16;
- partcode: SInt16;
- begin
- errCode := GetKeyboardFocus (mWindow, focus);
-
- ch := chr (charCode);
- if (ch = charEnter)
- | (ch = charReturn) then begin
- ExitCurField;
- end else if ch = charEsc then begin
- end else if ch = charTab then begin
- DoTab (BAnd (curEvent.modifiers, optionKey) <> 0);
- end else if focus <> nil then begin
- keyCode := BAnd (curEvent.message, keyCodeMask);
- partcode := HandleControlKey (focus, keyCode, charCode, curEvent.modifiers);
- mDoc.mEngine.SetDirty;
- end else begin
- SysBeep (1);
- end;
- end;
-
- {----------}
- Procedure Bars.Resize;
- begin
- { application-specific code to resize items in window }
- end;
-
- {----------}
- Procedure Bars.Scroll (
- newValue: integer;
- oldValue: integer);
- begin
- { application-specific code to scroll window }
- if gWhichScroll = vScroll then begin
- end else begin { horizontal }
- end;
- end;
-
- {----------}
- Procedure Bars.DoUndo;
- begin
- end; {DoUndo}
-
- {----------}
- Procedure Bars.DoCut;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TECut (curTE);
- mDoc.mEngine.SetDirty;
- scrapDirty := true;
- end;
- end; {DoCut}
-
- {----------}
- Procedure Bars.DoCopy;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TECopy (curTE);
- scrapDirty := true;
- end;
- end; {DoCopy}
-
- {----------}
- Procedure Bars.DoPaste;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TEPaste (curTE);
- mDoc.mEngine.SetDirty;
- end;
- end; {DoPaste}
-
- {----------}
- Procedure Bars.DoClear;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TEDelete (curTE);
- mDoc.mEngine.SetDirty;
- end;
- end; {DoClear}
-
- {----------}
- Procedure Bars.DoSelectAll;
- var
- curTE: TEHandle;
- begin
- curTE := GetCurTE ();
-
- if curTE <> nil then begin
- TESetSelect (0, 32767, curTE);
- end;
- end; {DoSelectAll}
-
- {----------}
- Procedure Bars.DoShowClipboard;
- begin
- end; {DoShowClipboard}
-
- {----------}
- Function Bars.DoCommand (
- inCommand: longint): Boolean;
- begin
- DoCommand := true;
- case inCommand of
- cmdUndo:
- DoUndo;
- cmdCut:
- DoCut;
- cmdCopy:
- DoCopy;
- cmdPaste:
- DoPaste;
- cmdClear:
- DoClear;
- cmdSelectAll:
- DoSelectAll;
- cmdShowClipboard:
- DoShowClipboard;
-
- otherwise
- DoCommand := false;
- end; {case}
- end;
-
- end.
-